import request from '@/utils/request'

// 获取access_token
export function accessToken(code) {
  return request({
    url: '/getAccessToken?code=' + code,
    method: 'get',
  })
}
// 获取用户信息
export function userInfo(token) {
  return request({
    url: '/getUserInfo?token=' + token,
    method: 'get',
  })
}

// login  userId,username
export function userLogin(data) {
  return request({
    url: '/queryStudentUser',
    method: 'post',
    data,
    transformRequest: [
      function (data) {
        let ret = ''
        for (let it in data) {
          ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&'
        }
        ret = ret.substring(0, ret.lastIndexOf('&'));
        return ret
      }
    ],
    headers: { // 设置请求头
      'Content-Type': 'application/x-www-form-urlencoded'
    }
  })
}


//获取学生分数
export function getStuInfo(params) {
  return request({
    url: '/queryStudentUserScore',
    method: 'post',
    params
  })
}

